package com.sh.data.engine.common.enumDefinition;

import java.util.Objects;

/**
 * @author tinglan.ys
 * @description:
 * @date 2022/3/30 下午4:57
 */
public enum TaskAlarmTypeEnum {
    FAILURE(0, "失败"),
    FINISH(1, "完成"),
    TIMEOUT(2, "运行超时"),
    NO_FINISH(3, "未完成"),
    SQL_ERROR(4, "sql语句出错"),
    DATA_QUALITY_ERROR(5, "数据质量问题"),
    STOP(6, "停止"),
    EXCEPTION(7, "异常"),
    DELAY(8, "延时"),
    FAILNUM(9, "同步失败条数"),
    MORE_THAN_RESOURCE_THRESHOLD(10, "资源超过阈值");

    int code;

    String name;

    TaskAlarmTypeEnum(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public int getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static String getNameByCode(Integer code) {
        Objects.requireNonNull(code);

        for (TaskAlarmTypeEnum taskAlarmTypeEnum : TaskAlarmTypeEnum.values()) {
            if (code == taskAlarmTypeEnum.code) {
                return taskAlarmTypeEnum.name;
            }
        }
        return null;
    }
}
